package com.java1234jdbc.chap02;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Demo1 {
    public static void main(String[] args) {
        //加载驱动类
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            long start=System.currentTimeMillis();
            //Connection conn=DriverManager.getConnection("jdbc:mysql//localhost:3306/testjdbc","root","root");
            Connection conn = DriverManager.getConnection("jdbc:mysql//localhost:3306/company?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8","root","root");
            long end=System.currentTimeMillis();
            System.out.println(conn);
            System.out.println("建立连接，耗时"+(end-start)+"ms毫秒");
        } catch (SQLException e) {
                e.printStackTrace();
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }
    }
}
